import http from "./http"

// 请求登录接口
interface loginData {
    email: string,
    password: string
}
function getLogin(data:loginData){
    return http.post("user/login",data)
}
// 请求首页数据
interface columnsData{
    currentPage:Number,
    pageSize:Number
}
function getColumns(params:columnsData){
    return http.get("columns",{params})
}
//请求进入专栏数据接口
interface idData {
    id: number
}
function getid(id:idData){
    return http.get(`columns/${id}`)
}
//请求专栏列表&&请求个人专栏列表接口
interface idList {
page:number,
size:number
}
interface idx {
    id: number,
}
function getidList(params:idList,id:idx){
    return http.get(`columns/${id}/posts?page=${params.page}&size=${params.size}`)
}
//请求单个文章接口
interface titleId {
    id: number
}
function gettitle(id:titleId){
    return http.get(`posts/${id}`)
}
//请求上传图片接口
function getfile(params:any){
    return http.post("upload",params)
}

// 请求发布文章接口
interface getposts{
    title: string,
    content:string,
    image?:string,
    column:string,
    author:string
}

function getpostsfb(params:getposts){
    return http.post('posts',params)
}
// 请求个人信息接口
function getloginid(){
    return http.get("user/current")
}
//请求个人专栏接口
interface goodsid{
    id: string
}
function getzlgoods(id:goodsid) {
    return http.get(`columns/${id}`)
}


export {getLogin, getColumns,getid,getidList,gettitle
    ,getfile,getpostsfb,getloginid,getzlgoods}
